﻿
/*
NAILSUPERSTORE ® COMPANY
 
[HISTORY]
Created By  	: NGUYEN VAN TY
Created Date	: 18/01/2010
Modified By     :
Modified Date   :
Note            :

*/

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CommonTagTime.DataAccess;
using CommonTagTime.ModelObject;
namespace CommonTagTime.Business
{
    public class busLogo
    {
        //------------------------------------------------
        //FIELD TABLE
        //------------------------------------------------

        public const string LogoId = "LogoId";
        public const string Title = "Title";
        public const string TitleEn = "TitleEn";
        public const string Link = "Link";
        public const string SortOrder = "SortOrder";
        public const string IsActive = "IsActive";
        public const string ImageFile = "ImageFile";
        public const string Target = "Target";
        public const string Position = "Position";
        public const string CreatedBy = "CreatedBy";
        public const string CreatedDate = "CreatedDate";
        public const string UpdatedBy = "UpdatedBy";
        public const string UpdatedDate = "UpdatedDate";
        public const string OrderBy = "OrderBy";
        public const string OrderDirection = "OrderDirection";
        public const string CurrentPage = "CurrentPage";
        public const string PageSize = "PageSize";
        public const string TotalRecords = "TotalRecords";
        public const string Condition = "Condition";


        private daoLogo _objDao;
        //------------------------------------------------
        //PUBLIC
        //------------------------------------------------
        public busLogo()
        {
            _objDao = new daoLogo();
        }       
        public bool OrderDown(int _logoId)
        {
            bool result = _objDao.OrderDown(_logoId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;          
        }
        public bool OrderUp(int _logoId)
        {
            bool result = _objDao.OrderUp(_logoId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;              
        }
        public bool Active(int _logoId)
        {
            bool result = _objDao.Active(_logoId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;           
        }
        public bool DeActive(int _logoId)
        {
            bool result = _objDao.DeActive(_logoId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;                 
        }
        public bool Delete(int _logoId)
        {           
            bool result = _objDao.Delete(_logoId);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;        
        }       
        public bool Insert(Logo objData)
        {
            bool result=_objDao.Insert(objData);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");            
            return result;
        }
        public bool Update(Logo objData)
        {
            bool result = _objDao.Update(objData);
            if (result)
                clsCacheUtil.RemoveCacheWithPrefix("Logo_");
            return result;          
        }
        public Logo GetByID(int _logoId)
        {
            string key = "Logo_GetByID_" + _logoId;
            Logo result = clsCacheUtil.GetCache(key) as Logo;
            if (result==null)
            {
                result = _objDao.GetByID(_logoId);
                clsCacheUtil.SetCache(key, result);
            }
            return result;
        }
        public LogoCollection List(Logo objCondition)
        {
            return _objDao.List(objCondition);
        }
        public LogoCollection GetByPosition(byte position)
        {            
            string key =  "Logo_GetByPosition_" + position;
            LogoCollection result = clsCacheUtil.GetCache(key) as LogoCollection;
            if (result == null)
            {            
                result=_objDao.GetByPosition(position);
                clsCacheUtil.SetCache(key, result);
            }
            return result;
        }
    }
}
